package day15;

import javax.swing.*;
public class ProductAndCustomerDemo {
    public static void main(String[] args) {

    }


}
class  Box{
    private  int content;
    private  boolean has;
    public  synchronized  void setContent(int content){
        if(has){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        this.content=content;
        has=true;
        notifyAll();
    }
    public  synchronized  int getContent() {
        if (has ==false){
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
         has=false;
        notifyAll();

    return  content;
    }
}
class  Cusomer extends  Thread{
    private Box box;
    public  Cusomer(Box box){this.box=box;}

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


    }
}
class Product extends Thread{

}